package com.example.moneybook.controller;

import com.example.moneybook.dto.ResponseResult;
import com.example.moneybook.pojo.Account;
import com.example.moneybook.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 包
 * @Date: 2023/2/24 15:01
 * Description:
 */
@RestController
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private AccountService accountService;

    @PostMapping("/addaccount")
    public ResponseResult addAccount(@RequestBody Account account){
        return accountService.addAccount(account);
    }

    @PostMapping("/loadaccount")
    public ResponseResult loadAccount(String userId){
        return accountService.loadAccount(userId);
    }

    @PostMapping("/useraccount")
    public ResponseResult getUserAccount(String userId){
        return accountService.getUserAccount(userId);
    }

    @PostMapping("/loadaccountbill")
    public ResponseResult loadAccountBill(String userId, int accountId, int listType){
        return accountService.loadAccountBill(userId, accountId,listType);
    }

    @PostMapping("/summoney")
    public ResponseResult sumMoney(String userId){
        return accountService.sumMoney(userId);
    }

    @PostMapping("/deleteaccount")
    public ResponseResult deleteAccount(String userId, int accountId){
        return accountService.deleteAccount(userId, accountId);
    }

    @PostMapping("/allinoutflow")
    public ResponseResult AllInOutflow(String userId, int accountId){
        return accountService.AllInOutflow(userId, accountId);
    }
}
